diff -ud autotrace-0.31.1/autotrace-config.in autotrace-0.31.1.patched/autotrace-config.in
--- autotrace-0.31.1/autotrace-config.in	2002-11-08 19:18:31.000000000 +0100
+++ autotrace-0.31.1.patched/autotrace-config.in	2015-08-31 01:22:03.777617655 +0200
@@ -4,6 +4,7 @@
 af_cflags=
 prefix=@prefix@
 exec_prefix=@exec_prefix@
+libdir=`pkg-config --variable=libdir autotrace`
 
 
 ##
@@ -205,7 +206,7 @@
 #dummy because this should always be selected
 
 af_cflags="$af_cflags -I@includedir@"
-af_libs="-L@libdir@ -lautotrace @LIBPNG_LDFLAGS@ @MAGICK_LDFLAGS@ @LIBSWF_LDFLAGS@ @LIBPSTOEDIT_LIBS@ $af_libs"
+af_libs="-L$libdir -lautotrace @LIBPNG_LDFLAGS@ @MAGICK_LDFLAGS@ @LIBSWF_LDFLAGS@ @LIBPSTOEDIT_LIBS@ $af_libs"
 
 
 
diff -ud autotrace-0.31.1/autotrace.m4 autotrace-0.31.1.patched/autotrace.m4
--- autotrace-0.31.1/autotrace.m4	2002-10-10 22:44:12.000000000 +0200
+++ autotrace-0.31.1.patched/autotrace.m4	2015-08-31 01:21:28.763826869 +0200
@@ -4,7 +4,7 @@
 dnl AM_PATH_AUTOTRACE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl Test to see if libautotrace is installed, and define AUTOTRACE_CFLAGS, LIBS
 dnl
-AC_DEFUN(AM_PATH_AUTOTRACE,
+AC_DEFUN([AM_PATH_AUTOTRACE],
 [dnl
 dnl Get the cflags and libraries from the autotrace-config script
 dnl
diff -ud autotrace-0.31.1/input-bmp.c autotrace-0.31.1.patched/input-bmp.c
--- autotrace-0.31.1/input-bmp.c	2002-10-10 22:44:08.000000000 +0200
+++ autotrace-0.31.1.patched/input-bmp.c	2015-08-31 01:21:44.767369265 +0200
@@ -166,7 +166,7 @@
                                                         /* 36 */
       Maps = 4;
     }
-  else if (Bitmap_File_Head.biSize <= 64) /* Probably OS/2 2.x */
+  else if (Bitmap_File_Head.biSize >= 40 && Bitmap_File_Head.biSize <= 64) /* Probably OS/2 2.x */
     {
       if (!ReadOK (fd, buffer, Bitmap_File_Head.biSize - 4))
 	{
diff -ud autotrace-0.31.1/input-magick.c autotrace-0.31.1.patched/input-magick.c
--- autotrace-0.31.1/input-magick.c	2002-10-29 04:42:05.000000000 +0100
+++ autotrace-0.31.1.patched/input-magick.c	2015-08-31 01:21:23.650426744 +0200
@@ -83,7 +83,11 @@
 
   for(j=0,runcount=0,point=0;j<image->rows;j++)
     for(i=0;i<image->columns;i++) {
+#if (MagickLibVersion < 0x0645) || (MagickLibVersion >= 0x0649)
       p=GetOnePixel(image,i,j);
+#else
+      GetOnePixel(image,i,j,pixel);
+#endif
       AT_BITMAP_BITS(bitmap)[point++]=pixel->red; /* if gray: red=green=blue */
       if(np==3) {
         AT_BITMAP_BITS(bitmap)[point++]=pixel->green;
diff -ud autotrace-0.31.1/input-png.c autotrace-0.31.1.patched/input-png.c
--- autotrace-0.31.1/input-png.c	2002-10-10 22:44:14.000000000 +0200
+++ autotrace-0.31.1.patched/input-png.c	2015-08-31 01:21:33.000548879 +0200
@@ -42,7 +42,7 @@
 
 static void handle_warning(png_structp png, const at_string message) {
         LOG1("PNG warning: %s", message);
-	at_exception_warning((at_exception_type *)png->error_ptr,
+	at_exception_warning((at_exception_type *)png_get_error_ptr(png),
 			     message);
 	/* at_exception_fatal((at_exception_type *)at_png->error_ptr,
 	   "PNG warning"); */
@@ -50,7 +50,7 @@
 
 static void handle_error(png_structp png, const at_string message) {
 	LOG1("PNG error: %s", message);
-	at_exception_fatal((at_exception_type *)png->error_ptr,
+	at_exception_fatal((at_exception_type *)png_get_error_ptr(png),
 			   message);
 	/* at_exception_fatal((at_exception_type *)at_png->error_ptr,
 	   "PNG error"); */
@@ -157,8 +157,8 @@
 
 	png_set_strip_16(png_ptr);
 	png_set_packing(png_ptr);
-	if ((png_ptr->bit_depth < 8) ||
-	    (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
+	if ((png_get_bit_depth(png_ptr, info_ptr) < 8) ||
+	    (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) ||
 	    (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
 		png_set_expand(png_ptr);
 
@@ -181,20 +181,10 @@
 				   PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
 	} else
 		png_set_strip_alpha(png_ptr);
+	png_set_interlace_handling(png_ptr);
 	png_read_update_info(png_ptr, info_ptr);
 
-
-	info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
-							info_ptr->height * sizeof(png_bytep));
-#ifdef PNG_FREE_ME_SUPPORTED
-	info_ptr->free_me |= PNG_FREE_ROWS;
-#endif
-	for (row = 0; row < (int)info_ptr->height; row++)
-		info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
-								    png_get_rowbytes(png_ptr, info_ptr));
-	
-	png_read_image(png_ptr, info_ptr->row_pointers);
-	info_ptr->valid |= PNG_INFO_IDAT;
+	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
 	png_read_end(png_ptr, info_ptr);
 	return png_get_rows(png_ptr, info_ptr);
 }

